package com.zzh.structuredeployment.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.zzh.bridge.page.PageApp
import com.zzh.bridge_annotation.RouteTag
import com.zzh.structuredeployment.R
import com.zzh.tools.utils.ToolIntent
import com.zzh.tools.utils.ToolLog
import kotlinx.android.synthetic.main.activity_six.*

@RouteTag(value = PageApp.COMPARE)
class SixActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_six)
        setClick()
    }

    private var one: Int = 0
    private var two: String = "0"
    private var three: Int = 0
    private var four: Int = 0
    private var five: Int = 0

    private fun setClick() {
        updateOne.setOnClickListener {
            one = if (one == 0) -1 else 0
            compareIntent()
        }
        updateTwo.setOnClickListener {
            two = if (two == "0") "-1" else "0"
            compareIntent()
        }
        updateThree.setOnClickListener {
            three = if (three == 0) -1 else 0
            compareIntent()
        }
        updateFour.setOnClickListener {
            four = if (four == 0) -1 else 0
            compareIntent()
        }
        updateFive.setOnClickListener {
            five = if (five == 0) -1 else 0
            compareIntent()
        }
        intent.putExtra("compare", hashMapOf<String, Any>())
    }

    private fun compareIntent() {
        var status = ToolIntent.compareParameters(
            intent,
            "one", one,
            "two", two,
            "three", three,
            "four", four,
            "five", five
        )
        showUpdate.text = ">${one}>${two}>${three}>${four}>${five}>${status}"
    }

}